const formatDateTime = (datetime) => {
  datetime = new Date(datetime)
  const year = datetime.getFullYear();
  const month = String(datetime.getMonth() + 1).padStart(2, '0'); // 月份从 0 开始，需要加 1
  const day = String(datetime.getDate()).padStart(2, '0');
  const hours = String(datetime.getHours()).padStart(2, '0');
  const minutes = String(datetime.getMinutes()).padStart(2, '0');
  const seconds = String(datetime.getSeconds()).padStart(2, '0');
  return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
}

const timestampFormatDateTime = (timestamp) => {
  let date = new Date(timestamp);
  const year = date.getFullYear();
  const month = String(date.getMonth() + 1).padStart(2, '0'); // 月份从 0 开始，需要加 1
  const day = String(date.getDate()).padStart(2, '0');
  const hours = String(date.getHours()).padStart(2, '0');
  const minutes = String(date.getMinutes()).padStart(2, '0');
  const seconds = String(date.getSeconds()).padStart(2, '0');
  return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
}
const timestampFormatDate = (timestamp) => {
  return timestampFormatDateTime(timestamp).substring(0, 10) + '';
}

export default {
  formatDateTime,
  timestampFormatDateTime,
  timestampFormatDate
}
